package com.ruoyi.business.controller.app;


import com.ruoyi.business.service.IWsdPaymentRecordsService;
import com.ruoyi.business.service.IWsdUserAccountService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.WsdPaymentRecords;
import com.ruoyi.common.core.domain.entity.WsdUserAccount;
import com.ruoyi.common.core.domain.vo.WxRechargeTypeVO;
import com.ruoyi.common.core.page.TableDataInfo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 充值缴费类型
 * </p>
 *
 * @author wwq
 * @since 2024-05-18
 */
@RestController
@RequestMapping("/wxRechargeType")
public class WxRechargeTypeController extends BaseController {
    @Autowired
    private IWsdPaymentRecordsService wsdPaymentRecordsService;
    @Autowired
    private IWsdUserAccountService wsdUserAccountService;
    @GetMapping("/list")
    public AjaxResult wxRechargeType(WsdPaymentRecords wsdPaymentRecords) {
        List<WsdPaymentRecords> list = wsdPaymentRecordsService.selectList(wsdPaymentRecords);
        WxRechargeTypeVO wxRechargeTypeVO = new WxRechargeTypeVO();
        wxRechargeTypeVO.setRechargeType( 2 );
        if (!list.isEmpty()){
            for (WsdPaymentRecords wsdPaymentRecord : list){
                if (wsdPaymentRecord.getBalanceFee().compareTo( BigDecimal.ZERO) == 0){
                    continue;
                }else if (wsdPaymentRecord.getBalanceFee().compareTo( BigDecimal.ZERO) > 0){
                    wxRechargeTypeVO.setRechargeType(wsdPaymentRecord.getRechargeType());
                }
            }
        }
        WsdUserAccount wsdUserAccount = new WsdUserAccount();
        wsdUserAccount.setUserId(getUserId());
        WsdUserAccount wsdUserAccount1 = wsdUserAccountService.selectWsdUserAccount( wsdUserAccount );
        if (wsdUserAccount1!=null) {
            wxRechargeTypeVO.setName( wsdUserAccount1.getName() );
            wxRechargeTypeVO.setPhone( wsdUserAccount1.getPhone() );
            wxRechargeTypeVO.setBankNumber( wsdUserAccount1.getBankNumber() );
            wxRechargeTypeVO.setAccountId( wsdUserAccount1.getAccountId() );
        }
        return AjaxResult.success(wxRechargeTypeVO);
    }

}
